package org.luxor.cloud.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.luxor.cloud.config.ExampleCloudConfiguration;
import org.luxor.cloud.config.properties.ExampleCloudProperties;
import org.luxor.commons.core.web.controller.BaseRestController;
import org.luxor.commons.core.web.data.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @author Mr.Yan  @date: 2020/9/1
 */
@RestController
@RequestMapping(value = "/config")
@Api(tags = "系统配置")
public class ConfigController extends BaseRestController {

    @Resource
    private ExampleCloudConfiguration configuration;
    @Resource
    private ExampleCloudProperties properties;

    @GetMapping("/refresh")
    @ApiOperation("启用自动刷新配置？")
    public R get() {
        Map<String, Boolean> result = new HashMap<>();
        result.put("方式一:@RefreshScope注解标注", configuration.isEnabled());
        result.put("方式二:@EnableConfigurationProperties注解引入", properties.isEnabled());
        return R.ok(result);
    }


}
